package org.charry.lib.commons.log;

import org.apache.commons.logging.Log;

/**
 * A utiltiy class for trace the stack.
 * 
 * @author wcharry
 * 
 */
public final class StackUtility {
	/**
	 * Dummy constructor.
	 */
	private StackUtility() {
		// NOOP
	}

	/**
	 * Save exception stack to log file.
	 * 
	 * @param log
	 *            handler to log
	 * @param e
	 *            exception to be traced
	 */
	public static void logStackTrace(final Log log, final Exception e) {
		log.error(e);

		StackTraceElement[] s = e.getStackTrace();
		for (int i = 0; i < s.length; i++) {
			log.error(s[i]);
		}
	}
}
